package org.egedede.osgi.guishell.model.commands;

import java.io.PrintStream;
import java.util.Properties;

import org.egedede.osgi.guishell.model.AbstractCommand;
import org.egedede.osgi.guishell.model.CommandType;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;

public class StopBundleCommand extends AbstractCommand {


	public StopBundleCommand() {
		super("Stop", "Stop a bundle", CommandType.BUNDLE);
	}

	public Object execute(Properties properties, PrintStream out, PrintStream error) {
		Object property = properties.get("bundle.id");
		long parseInt = (Long)property;
		Bundle bundle = getContext().getBundle(parseInt);
		try {
			bundle.stop();
		} catch (BundleException e) {
			e.printStackTrace(error);
		}
		return null;
	}

}
